<?php
/**
 * Created by PhpStorm.
 * User: xiaom
 * Date: 2016/9/24 0024
 * Time: 19:38
 */

namespace Net\Model;

use Think\Model\ViewModel;

class FailuresRepairModel extends ViewModel  {
    public $viewFields=array(
        'FailuresRepair'=>array('id','name','account','mobile','room_number','description','creation_time','_type'=>'LEFT'),
        'Operator'=>array('title'=>'operator_title','_on'=>'FailuresRepair.operator_id=Operator.id','_type'=>'LEFT'),
        'Building'=>array('title'=>'building_title','_on'=>'FailuresRepair.building_id=Building.id','_type'=>'LEFT'),
        'Campus'=>array('title'=>'campus_title','_on'=>'Building.campus_id=Campus.id','_type'=>'LEFT'),
        'FaultType'=>array('title'=>'fault_type_title','_on'=>'FailuresRepair.fault_type_id=FaultType.id','_type'=>'LEFT'),
        'Orders'=>array('id'=>'order_id','status','user_id','order_time','handle_time','user_comment','admin_comment','_on'=>'FailuresRepair.id=Orders.failures_repair_id','_type'=>'LEFT'),
        'Users'=>array('user_login'=>'admin_name','_on'=>'Orders.user_id=Users.id','_type'=>'LEFT'),
    );

//    protected $_link=array(
//        'operator'=>array(
//            'mapping_type'=>self::BELONGS_TO,
//            'foreign_key'=>'operator_id',
//            'as_fields'=>'title:operator_title'
//        ),
//        'building'=>array(
//            'mapping_type'=>self::BELONGS_TO,
//            'foreign_key'=>'building_id',
//            'as_fields'=>'title:building_title,campus_id'
//        ),
//        'campus'=>array(
//            'mapping_type'=>self::BELONGS_TO,
//            'foreign_key'=>'campus_id',
//            'as_fields'=>'title:campus_title'
//        ),
//        'FaultType'=>array(
//            'mapping_type'=>self::BELONGS_TO,
//            'foreign_key'=>'fault_type_id',
//            'as_fields'=>'title:fault_type_title'
//        ),
//        'order'=>array(
//            'mapping_type'=>self::HAS_ONE,
//            'foreign_key'=>'failures_repair_id',
//            'as_fields'=>'user_comment_id,user_id,order_status,handle_status,admin_comment_id,order_time,handle_time'
//        ),
//        'users'=>array(
//            'mapping_type'=>self::BELONGS_TO,
//            'foreign_key'=>'user_id',
//            'as_fields'=>'user_login:admin_name'
//        ),
//        'comment'=>array(
//            'mapping_type'=>self::BELONGS_TO,
//            'foreign_key'=>'user_comment_id',
//            'as_fields'=>'content:user_comment,score'
//        ),
//        'comment2'=>array(
//            'class_name'=>'comment',
//            'mapping_type'=>self::BELONGS_TO,
//            'foreign_key'=>'admin_comment_id',
//            'as_fields'=>'content:admin_comment'
//        ),
//
//    );
}